define(["app","js/risk/mainView","js/init", 'js/utils','js/util/socketUtil','js/risk/riskModel',"text!app/risk/main.html"], 
	function(app, riskView,base,Utils,initSocket,model,source) {
	
	
	var $$ = Dom7;
	var bindings = [		
		//类型链接
		{
			element: '.risk-grid .type-link',
			event: 'click',
			handler: clickType
		}		
	];

	

	function clickType(e){


		if(!app.mainView){
			app = app.getApp();
		}

		
		
		var typeCode ,typeName
		if(e && e.currentTarget){
			typeCode = $(e.currentTarget).attr('pid')
			typeName = $(e.currentTarget).attr('pname')
			
			model.setCC({
				typeCode:typeCode,
				typeName:typeName
			})
		}
		
		
		if(typeCode){

			
			var _cv = app.f7.getCurrentView();			
			var _router
			if(_cv){
				_router = _cv.router			
			}else{
				_router = app.f7.views.risk.router			
			}
			app.f7.showPreloader('loading...');
			_router.load({url:'app/risk/type.html',
				query:{
					code:typeCode,
					name:typeName
				}
			});
			//_router.reloadPage('app/risk/'+typeCode + '.html');
		}
	}

	function init(query){	
		
				
		
		riskView.render({
			model	: model.module,
			bindings: bindings
		});
		
		//var _el = $('#risk-page .type-link')
		//$(_el).unbind('click')
		//$(_el).bind('click',clickType);
	}

	return {
		init: init
	};
});